package com.dex4d.ui.dapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;

import com.dex4d.R;
import com.dex4d.core.AppToolBarBaseActivity;
import com.dex4d.ui.dapp.adapter.WebPagerAdapter;
import com.dex4d.ui.demo.HomeActivity;

import butterknife.BindView;

public class WebHistoryActivity extends AppToolBarBaseActivity implements HistoryFragment.OnDappBookMarkListener {

    public static void start(Activity activity) {
        Intent intent = new Intent(activity, WebHistoryActivity.class);
        activity.startActivityForResult(intent, HomeActivity.REQUEST_CODE_DAPP_WEB);
    }

    @BindView(R.id.tablayout)
    TabLayout tabLayout;

    @BindView(R.id.viewpager)
    NoSrcollViewPage viewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_web_history;
    }

    @Override
    protected void initVariables() {
        tabLayout.setupWithViewPager(viewPager);
        viewPager.setAdapter(new WebPagerAdapter(this, getSupportFragmentManager()));

        tabLayout.addOnTabSelectedListener(new TabLayout.BaseOnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                if (tab.getPosition() == 0) {
                    showRightImage();
                } else {
                    slectedHistoryTag();
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
    }

    @Override
    protected void loadData() {

    }

    @Override
    protected void initToolbar() {
        showTitle(getResources().getString(R.string.dapp_bookmark));
        showRightImage();
    }

    @Override
    public void onDappHistory() {
        slectedHistoryTag();
    }

    @Override
    public void onDappBookmark() {
        showRightImage();
    }

    @Override
    public void reset() {
        dappReset();
    }
}
